﻿#region 程序集引用
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
using Zhang.key;

#endregion

#region 版权注释
/*===========================================================================
// Copyright (C) 2016 seabay.cn，并保留所有 
// 作者：吴岸标 QQ:405403610
// 创建日期：2016-06-05
// 功能描述： 平台后台基类 Controller
===========================================================================*/
#endregion

namespace Zhang
{
    namespace AdminPage
    {
        /// <summary>
        /// 平台后台基类 Controller
        /// </summary>
        public partial class BaseController : System.Web.Mvc.Controller
        {
            private static readonly bool WhiteLog = bool.Parse(ConfigurationManager.AppSettings["WhiteLog"] == null ? "true" : ConfigurationManager.AppSettings["WhiteLog"]);
            /// <summary>
            /// 指定当前页面是否是在对话窗口中
            /// </summary>
            protected bool IsDialogPage = false;
            /// <summary>
            /// 当前页面功能名称
            /// </summary>
            protected string ModelName { get; set; }
            /// <summary>
            /// 用户信息
            /// </summary>
            protected Model.AdminUser UserInfo { get; set; }
            /// <summary>
            /// 操作提示内容
            /// </summary>
            protected string MessageContent = string.Empty;
            /// <summary>
            /// 操作完成默认返回链接
            /// </summary>
            protected Model.Link DefaultBackLink = null;


            protected override void OnAuthorization(AuthorizationContext filterContext)
            {
                base.OnAuthorization(filterContext);

                // 判断用户是否登陆
                //if (Session[SessionKey.ADMIN_USER_INFORMATION] != null)
                //{
                //    UserInfo = Session[SessionKey.ADMIN_USER_INFORMATION] as Model.AdminUser;
                //}
                //else
                //{
                  
                //    Response.ClearContent();
                //    Response.Write("请登录");
                //    Response.End();
                //}

               
            }

            /// <summary>
            /// 显示操作提示内容(变量MessageContent内容)
            /// </summary>
            /// <param name="msgType">提示类型</param>
            protected void ShowMessage(Model.MessageType msgType)
            {
                string msg = string.Empty;
                var message = string.IsNullOrEmpty(MessageContent) ? (msgType == Model.MessageType.Failure ? "操作失败" : "操作完成") : MessageContent;



                msg = message + $" 请重试";
                

                Response.ClearContent();
                Response.Write(msg);
                Response.End();
                //throw new Exception("提示消息");


            }

        }
    }
}
